package com.weiyi.mashangzhu.Roomer.Adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.weiyi.mashangzhu.API.API;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Bean.AllCommentInfo;
import com.weiyi.mashangzhu.Utils.GlideImgManager;

import java.util.List;

/**
 * Created by win7 on 2017/5/12.
 */

public class AllCommentAdapter extends BaseAdapter {
    List<AllCommentInfo.DataBean.EvalistBean> list;
    Context context;

    public AllCommentAdapter(List<AllCommentInfo.DataBean.EvalistBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_all_comment, null);
            viewHolder.head = (ImageView) convertView.findViewById(R.id.head);
            viewHolder.time = (TextView) convertView.findViewById(R.id.time);
            viewHolder.content = (TextView) convertView.findViewById(R.id.content);
            viewHolder.name = (TextView) convertView.findViewById(R.id.name);
            convertView.setTag(viewHolder);

        }
        viewHolder = (ViewHolder) convertView.getTag();
        GlideImgManager.glideLoader(context, API.BaseApi_url + list.get(position).getCustomerHead(), R.mipmap.errer, viewHolder.head, 0);
        viewHolder.name.setText(list.get(position).getCustomerName() + "");
        viewHolder.time.setText(list.get(position).getETime() + "");
        viewHolder.content.setText(list.get(position).getEContent() + "");
        return convertView;
    }

    class ViewHolder {
        ImageView head;
        TextView name, time, content;
    }
}
